package com.lehoon.tomato.controller;

import com.lehoon.tomato.model.User;
import com.lehoon.tomato.model.common.Result;
import com.lehoon.tomato.model.vo.LoginVo;
import com.lehoon.tomato.model.wechat.WxAuthCodeMessage;
import com.lehoon.tomato.service.LoginService;
import com.lehoon.tomato.service.UserService;
import com.lehoon.tomato.service.WeChatService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@Api(description = "登录相关接口")
@RestController
@RequestMapping("/unauth/")
public class LoginController {

    @Resource
    private UserService userService;
    @Resource
    private LoginService loginService;

    @GetMapping("wxLogin")
    @ApiOperation(value = "微信小程序登录")
    @ApiImplicitParam(name="code",value="用户code",dataType="string", paramType = "query")
    public Result<LoginVo> wxLogin(String code){
        LoginVo vo =  loginService.doWxLogin( code);
        return Result.successResult(vo);
    }
}
